package map.landArea;

import java.util.Scanner;

public class Main {
    static int[][] dir = new int[][]{{0,1},{1,0},{-1,0},{0,-1}};
    public static int dfs(boolean[][] visited, int[][] grid, int x, int y){
        int area = 1;
        for (int i = 0; i < 4; i++) {
            int nextX = x + dir[i][0];
            int nextY = y + dir[i][1];
            if (nextX < 0 || nextY < 0 || nextX >= grid.length || nextY >= grid[0].length){
                continue;
            }
            if (!visited[nextX][nextY] && grid[nextX][nextY] == 1){
                visited[nextX][nextY] = true;
                area += dfs(visited, grid, nextX, nextY);
            }
        }
        return area;
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int rows = scanner.nextInt();
        int cols = scanner.nextInt();
        int[][] lands = new int[rows][cols];
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                lands[i][j] = scanner.nextInt();
            }
        }
        boolean[][] visited = new boolean[rows][cols];
        int result = 0;
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                if (!visited[i][j] && lands[i][j] == 1){
                    visited[i][j] = true;
                    result = Math.max(result, dfs(visited, lands, i, j));
                }
            }
        }
        System.out.println(result);
    }
}
